import ModalApi from '@/components/SwModal/api.js'
import router from '@/router/index.js'
import LoginService from '@/service/LoginService.js'

let codeHandles = {
  // 未登录
  '51001': (opts = {}) => {
    let handle = ModalApi.confirm(Object.assign({
      modalClass: 'commonModal',
      isShowCloseBtn: true,
      isCloseOnClickBg: true,
      id: '51001',
      title: 'prompt message',
      content: '51001', // '你当前未登录',
      noText: '', // '取消',
      okText: 'Login On', // '去登录',
      isShowBg: true,
      ok: () => {
        handle.close()
        router.push({path: '/user/login'})
      }
    }, opts))
    LoginService.clearUserInfo()
    return handle
  },
  // 登录过期
  '42011': () => {
    let handle = ModalApi.confirm({
      modalClass: 'commonModal',
      isShowCloseBtn: true,
      isCloseOnClickBg: true,
      id: '42011',
      title: 'prompt message',
      content: '42011', // '登录过期',
      noText: '', // '取消',
      okText: 'Login On', // '去登录',
      isShowBg: true,
      ok: () => {
        handle.close()
        router.push({path: '/user/login'})
      }
    })
    LoginService.clearUserInfo()
  },
  // 登录未验证
  '42024': () => {
    let handle = ModalApi.confirm({
      modalClass: 'commonModal',
      isShowCloseBtn: true,
      isCloseOnClickBg: true,
      id: '42024',
      title: 'prompt message',
      content: '51001', // 登录未验证,
      noText: '', // '取消',
      okText: 'Login On', // '去登录',
      isShowBg: true,
      ok: () => {
        handle.close()
        router.push({path: '/user/login'})
      }
    })
  },
  // 另处登录
  '42025': () => {
    let handle = ModalApi.confirm({
      modalClass: 'commonModal',
      isShowCloseBtn: true,
      isCloseOnClickBg: true,
      id: '42025',
      title: 'prompt message',
      content: '42025', // '您的账号已在别地登录，如不是本人操作，请尽快修改密码',
      noText: '', // '取消',
      okText: 'Login On', // '去登录',
      isShowBg: true,
      ok: () => {
        handle.close()
        router.push({path: '/user/login'})
      }
    })
    LoginService.clearUserInfo()
  }
}

export default codeHandles
